<%@page import="com.zt.exp5.bean.Car"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

  </head>
  
  <body>
  	<jsp:useBean id="car" class="com.zt.exp5.bean.Car" scope="session"></jsp:useBean>
    <%
    	request.setCharacterEncoding("utf-8");
    	String action = (String)request.getParameter("action");
    	if("buy".equals(action)){
    		int id = Integer.parseInt((String)request.getParameter("id"));
    		car.buy(id, 1);
    		request.getRequestDispatcher("buy1.jsp").forward(request, response);
    	}else if("showCar".equals(action)){
    		request.getRequestDispatcher("showCar1.jsp").forward(request, response);
    	}else if("remove".equals(action)){
    		int id = Integer.parseInt((String)request.getParameter("id"));
    		car.remove(id, 1);
    		request.getRequestDispatcher("showCar1.jsp").forward(request, response);
    	}else if("clear".equals(action)){
    		car.clear();
    		request.getRequestDispatcher("showCar1.jsp").forward(request, response);
    	}
    %>
  </body>
</html>
